""" 全局错误定义，抛出的错误处理 """


class MyException(Exception):
    """
    错误定义，需要自定义报警可以实例化后自行添加，不要修改全局错误定义
    """
    ### req
    ERROR_AUTH = (1, '无权限请求数据')
    ERROR_REQ = (2, '无效的请求')
    ERROR_REQ_PARAM = (3, '无效的请求,缺少关键参数')
    ERROR_REQ_DATA = (4, '无效的请求,请求数据错误')
    ### program
    ERROR_PROGRAMMA = (10, '程序错误')
    ERROR_BUSINESS_LOGIC = (11, '业务逻辑错误')
    ERROR_LINK_SERVER = (12, '连接服务器错误')
    ERROR_PLUGIN = (20, '插件程序错误')
    ### db
    ERROR_DATABASE_CONN = (30, '数据库连接错误')
    ERROR_DATABASE_WORK = (31, '数据库处理错误')
    ERROR_DATABASE_EXEC = (32, '数据库执行错误')
    ### dev
    ERROR_DEV_CONN = (40, '设备连接错误')
    ERROR_DEV_WORK = (41, '设备处理错误')
    ERROR_DEV_CONTROL_FAIL = (42, '设备控制失败')
    ### http
    ERROR_UNKNOW = (500, '访问错误')  # 网络访问的未知，不确定错误

    def __init__(self, tuple):
        self.args = tuple

